home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / miscnix.zip / STRNCHR.A < prev    next >
Text File  |  1988-05-20  |  493b  |  29 lines

  1. ;STRNCHR - Search for matching character.
  2. ;    char *strnchr(addr: address; len: integer; pat: char);
  3.  
  4. ;    This is like strchr (=index) except that it works with fixed length
  5. ;    strings.
  6.  
  7.     cseg
  8.     public    strnchr_
  9.  
  10. strnchr_:pop    bx
  11.     pop    di        ;start address
  12.     pop    cx        ;length
  13.     pop    ax        ;character to match
  14.     push    ax
  15.     push    cx
  16.     push    di
  17.     push    bx
  18.  
  19.     cld
  20.     push    ds
  21.     pop    es
  22.     jcxz    s1        ;if not found
  23.     repne    scasb
  24.     jne    s1        ;if not found
  25.     dec    di        ;if found, back up
  26. s1:    xchg    ax,di
  27.     ret
  28.     end
  29.